package com.rd.teacher.jichao.day03;

public class RuntimeTest {

    public static void main(String[] args) throws Exception{
//        Process process = null;
//        // 是一种饿汉式的单例
//        Runtime runtime = Runtime.getRuntime();
//        process = runtime.exec("notepad");

        Runtime runtime = Runtime.getRuntime();
        // 处理器个数
        System.out.println(runtime.availableProcessors());
        // 最大内存 以字节为单位
        System.out.println(runtime.maxMemory());
        // 总内存
        System.out.println(runtime.totalMemory());
        // 剩余内存
        System.out.println(runtime.freeMemory());


        for (int i = 0; i < 1000; i++) {
            new Object();
        }
        System.out.println(runtime.freeMemory());
        runtime.gc();
        System.out.println(runtime.freeMemory());

    }
}
